<%@ taglib uri="/WEB-INF/myfaces_html.tld" 	prefix="h" %>
<%@ taglib uri="/WEB-INF/myfaces_core.tld" 	prefix="f" %>
<%@ taglib uri="/WEB-INF/tomahawk.tld"     	prefix="t" %>
<%@ taglib uri="/WEB-INF/myfaces_sandbox.tld"   prefix="s" %>
<%@ page import="java.util.ArrayList" %>

<f:view>
    <jsp:include page="/intestazione.jsp">
        <jsp:param name="titolo" value="Gestione Fornitore"/>
    </jsp:include>
    <jsp:include page="/menu.jsp"/>
    <script language="javascript" src="./script/popup_full_center.js"></script>
    <script language="javascript" src="./script/confirmCM.js"></script>    
    <script language="javascript" src="./script/ripristinoSessione.js"></script>
    <t:saveState value="#{tabFornitore.selectedTabIndex}"/>

    <table class="find" style="border: 2pt solid white; margin-bottom: -10px">
        <hr />
        <tr>  
            <td class="intestazionePagina" align="center">
            <strong>GESTIONE FORNITORI</strong></td>                        
        </tr>        
    </table>
    
    <f:verbatim><br/></f:verbatim>
    <t:panelTabbedPane id="panelTabbedPane" selectedIndex="#{tabFornitore.selectedTabIndex}" serverSideTabSwitch="true" style="margin-left: 2px">
        <t:tabChangeListener type="it.azienda.managerworkstandard.view.TabFornitore"/>

        <t:panelTab id="tab0" label="Fornitore">                               

            <h:form>    
            </h:form>
           
            <t:saveState value="#{beanFornitore}"/>            
    
            <h:form id="formLookup" binding="#{dettaglioFornitore.form}">  
                <f:verbatim><table class="dettaglio" >
                    <tbody>          
                    <span>
                        <tr>                   
                            <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="codice" value="Cod.Fornitore (*)"/><f:verbatim></strong></td>
                            <td></f:verbatim><t:inputText id="codice" value="#{beanFornitore.codice}" size="10" maxlength="10" styleClass="dettaglio_InputText" immediate="true" disabled="false"/><f:verbatim></td>          
            
                            <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="descrizioneCategoriaFor" value="Categoria:" /><f:verbatim></strong></td>
                            <td></f:verbatim>
                            <t:inputText id="descrizioneCategoriaFor" value="#{beanFornitore.beanCategoriaFor.descrizione}" onchange="submit()" valueChangeListener="#{dettaglioFornitore.lookUp}" size="15" styleClass="dettaglio_InputText">
                                <f:attribute name="nomeBean" value="beanCategoriaFor" />
                                <f:attribute name="nomeBeanLookUp" value="CategoriaFor" />
                            </t:inputText>
                            <t:inputText id="codiceCategoriaFor" value="#{beanFornitore.beanCategoriaFor.codice}" styleClass="dettaglio_InputText" size="5" disabled="true"/>
                            <f:verbatim></td>
                            <td></f:verbatim>
                            <t:commandLink id="cercaLookup2" onclick="loadurl('lookup/lookupCategoriaFor.jsf?lookup=descrizioneCategoriaFor');" immediate="true">
                                <t:graphicImage url="image/system-search.png" border="0" title="Cerca Elemento"/>
                            </t:commandLink>
                            <f:verbatim></td><td></f:verbatim>
                            <t:commandLink action="#{dettaglioFornitore.svuotaLookup}" title="Svuota" rendered="#{beanFornitore.beanCategoriaFor.id ne null}">
                                <t:graphicImage url="image/edit-redo.png" border="0" title="Indietro"/>
                                <f:param name="bean" value="beanCategoriaFor"/>                        
                            </t:commandLink>
                            <f:verbatim></td>
                        </tr>             
                    </span>
                    <tr>                   
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="ragioneSociale" value="Cognome/Ragione Sociale (*)"/><f:verbatim></strong></td>
                        <td colspan="3"></f:verbatim><t:inputText id="ragioneSociale" value="#{beanFornitore.ragioneSociale}" size="80" maxlength="100" styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()" required="true"/>
                        <f:verbatim><br/></f:verbatim>
                        <h:message style="color: red" for="ragioneSociale" showDetail="true" showSummary="false" />
                        <f:verbatim></td>
                    </tr>
                    <tr>
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="descrBreve" value="Anagrafica dettaglio"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputTextarea id="descrBreve" value="#{beanFornitore.descrBreve}" rows="3" cols="50"  required="false" styleClass="dettaglio_InputText"/><f:verbatim></td>
                    </tr>
            
                    <tr>                   
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="codiceFiscale" value="Codice Fiscale"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="codiceFiscale" value="#{beanFornitore.codiceFiscale}" size="20" maxlength="16" onchange="this.value=this.value.toUpperCase()" styleClass="dettaglio_InputText"/>
                        <f:verbatim></td>
                     
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="partitaIva" value="Partita Iva"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="partitaIva" value="#{beanFornitore.partitaIva}" size="20" maxlength="20" required="false" styleClass="dettaglio_InputText"/><f:verbatim></td>
                    </tr>   
                            
                    <tr>                   
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="indirizzo" value="Indirizzo"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="indirizzo" value="#{beanFornitore.indirizzo}" size="55" maxlength="50" styleClass="dettaglio_InputText" required="false"/>
                        <f:verbatim></td>
                    </tr>    
                    <tr>
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="descrizioneComune_Residenza" value="Comune di Residenza" /><f:verbatim></strong></td>
                        <td></f:verbatim>
                        <t:inputText id="descrizioneComune_Residenza" value="#{beanFornitore.beanComuneResidenza.descrizione}" onchange="submit()" valueChangeListener="#{dettaglioFornitore.lookUp}" size="45" styleClass="dettaglio_InputText">
                            <f:attribute name="nomeBean" value="beanComuneResidenza" />
                            <f:attribute name="nomeBeanLookUp" value="Comune" />
                        </t:inputText>
                        <t:inputText id="cap_Residenza" value="#{beanFornitore.beanComuneResidenza.cap}" styleClass="dettaglio_InputText" size="5" disabled="true"/>
                        <f:verbatim><br/></f:verbatim>
                        <h:message style="color: red" for="descrizioneComune_Residenza" showDetail="false" showSummary="true" />
                        <f:verbatim></td>   
                        <td></f:verbatim>                
                        <t:commandLink id="cercaLookup1" onclick="loadurl('lookup/lookupComuni.jsf?lookup=descrizioneComune_Residenza');" immediate="true">
                            <t:graphicImage url="image/system-search.png" border="0" title="Cerca Elemento"/>
                        </t:commandLink>
                        <f:verbatim></td><td></f:verbatim>
                        <t:commandLink action="#{dettaglioFornitore.svuotaLookup}" title="Svuota" rendered="#{beanFornitore.beanComuneResidenza.id ne null}">
                            <t:graphicImage url="image/edit-redo.png" border="0" title="Indietro"/>
                            <f:param name="bean" value="beanComuneResidenza"/>                        
                        </t:commandLink>
                        <f:verbatim></td>
                    </tr>         
              
                    <tr>                   
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="telefono" value="Numero telefono"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="telefono" value="#{beanFornitore.telefono}" size="20" maxlength="20" required="false" onchange="this.value=this.value.toUpperCase()" styleClass="dettaglio_InputText"/><f:verbatim></td>
                
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="telefono2" value="Numero telefono 2"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="telefono2" value="#{beanFornitore.telefono2}" size="20" maxlength="20" required="false" onchange="this.value=this.value.toUpperCase()" styleClass="dettaglio_InputText"/><f:verbatim></td>
                    </tr>            
                    <tr>
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="cellulare" value="Numero cellulare"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="cellulare" value="#{beanFornitore.cellulare}" size="20" maxlength="20" required="false" onchange="this.value=this.value.toUpperCase()" styleClass="dettaglio_InputText"/><f:verbatim></td>
         
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="fax" value="Fax"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="fax" value="#{beanFornitore.fax}" size="20" maxlength="20" required="false" onchange="this.value=this.value.toUpperCase()" styleClass="dettaglio_InputText"/><f:verbatim></td>
                    </tr>
                    <tr>
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="email" value="Email"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="email" value="#{beanFornitore.email}" size="40" maxlength="45" required="false" styleClass="dettaglio_InputText"/><f:verbatim></td>

                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="web" value="Web"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputText id="web" value="#{beanFornitore.web}" size="20" maxlength="45" required="false" styleClass="dettaglio_InputText"/><f:verbatim></td>
                    </tr>
                    <tr>
                        <td class="etichettaDettaglio"><strong></f:verbatim><t:outputLabel for="note" value="Note"/><f:verbatim></strong></td>
                        <td></f:verbatim><t:inputTextarea id="note" value="#{beanFornitore.note}" rows="5" cols="50"  required="false" styleClass="dettaglio_InputText"/><f:verbatim></td>
                    </tr>
                </table>
                <br/></f:verbatim>
                <t:inputHidden id="idFornitore" value="#{beanFornitore.id}"/>        
                <t:inputHidden value="#{beanFornitore.id}"/>
                <f:verbatim><table bgcolor="#FFFFFF" width="750px">
                    <tr>     
                        <td></f:verbatim>
                        <h:commandLink styleClass="commandLink_Style" dir="RTL" action="benvenuto" immediate="true">
                            <t:graphicImage url="/image/go-home.png" border="0"/>
                        </h:commandLink>              
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <t:commandLink action="#{dettaglioFornitore.primo}"  rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/primo.png" border="0" title="Vai al primo elemento"/>
                            <f:param name="bean" value="beanFornitore"/>                        
                            <f:param name="id" value="#{beanFornitore.id}"/>                 
                        </t:commandLink>
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <t:commandLink action="#{dettaglioFornitore.precedente}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/indietro.png" border="0" title="Indietro"/>
                            <f:param name="bean" value="beanFornitore"/>                        
                            <f:param name="id" value="#{beanFornitore.id}"/>                 
                        </t:commandLink>
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <t:commandLink action="#{dettaglioFornitore.successivo}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/avanti.png" border="0" title="Avanti"/>
                            <f:param name="bean" value="beanFornitore"/>                        
                            <f:param name="id" value="#{beanFornitore.id}"/>                 
                        </t:commandLink>
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <t:commandLink action="#{dettaglioFornitore.ultimo}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/ultimo.png" border="0" title="Vai all'ultimo elemento"/>
                            <f:param name="bean" value="beanFornitore"/>                        
                            <f:param name="id" value="#{beanFornitore.id}"/>                 
                        </t:commandLink>
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <h:commandLink dir="RTL" onmousedown="return confirmDelete(this);" title="cancella" action="#{dettaglioFornitore.cancella}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/stop.png" border="0" title="Cancella"/>
                            <f:param name="bean" value="beanFornitore" />
                        </h:commandLink>                
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <h:commandLink dir="RTL" onmousedown="return confirmUpdate(this);" title="modifica" action="#{dettaglioFornitore.modifica}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/salva.png" border="0" title="Salva modifiche"/>
                            <f:param name="bean" value="beanFornitore" />
                        </h:commandLink>                
                        <f:verbatim></td>   
                        <td></f:verbatim>
                        <h:commandLink dir="RTL" onmousedown="return confirmSave(this);" title="salva inserimento" action="#{dettaglioFornitore.inserisci}" rendered="#{beanFornitore.id eq null}">
                            <t:graphicImage url="image/salva.png" border="0" title="Salva inserimento"/>
                            <f:param name="bean" value="beanFornitore" />
                        </h:commandLink>                
                        <f:verbatim></td></f:verbatim>
                        <%--
                        <td>
                        <h:commandLink dir="RTL" title="Annulla operazione" action="#{dettaglioFornitore.annulla}" rendered="#{beanFornitore.id eq null}" immediate="true">
                        <t:graphicImage url="image/delete.png" border="0"/>
                        <f:param name="bean" value="beanFornitore" />
                        </h:commandLink>                     
                        </td>
                        --%>
                        <f:verbatim><td></f:verbatim>
                        <h:commandLink dir="RTL" title="inserisce nuovo elemento" action="#{dettaglioFornitore.inserisciDettaglio}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/nuovo.png" border="0" title="Inserisci NUOVO"/>
                            <f:param name="bean" value="beanFornitore" />
                        </h:commandLink>
                        <f:verbatim></td>
                        <td></f:verbatim>
                        <h:commandLink  title="LISTA" id="lista" action="#{dettaglioFornitore.lista}" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/lista.png" border="0" title="Carica lista" style="width:32px; height:32px"/>
                            <f:param name="bean" value="Fornitore" />
                        </h:commandLink>
                        <f:verbatim></td>               
                        <td></f:verbatim>                
                        <t:commandLink id="cerca1" onclick="loadurl('pages_ricerca/ricercaFornitori.jsf');" immediate="true" rendered="#{beanFornitore.id ne null}">
                            <t:graphicImage url="image/find.png" border="0" title="Cerca Elemento" style="width:32px; height:32px"/>
                        </t:commandLink>
                        <f:verbatim></td>   
     
                        <td></f:verbatim>                
                        <t:commandLink id="aiuto" onclick="loadurl('info/legendaBottoniDettaglio.jsf');" immediate="true">
                            <t:graphicImage url="image/help.png" border="0" title="Aiuto"/>
                        </t:commandLink>
                        <f:verbatim></td> 
                    </tr>
                </table></f:verbatim>
            </h:form>
        </t:panelTab>
        
        <t:panelTab id="tab3Cli" label="Situazione Fornitore">
            <f:verbatim><div  style="overflow: scroll; width:750px; height: 400px; white-space: nowrap; wrap: off"></f:verbatim>
            <t:dataTable id="listaPrimaNota" var="lista" value="#{gestisci.listaStorico2}" preserveDataModel="true"           
                styleClass="dataTableGestisci_Table2" 
                headerClass="dataTableGestisci_Header"
                rowClasses="dataTableGestisci_Row1, dataTableGestisci_Row2"          
                columnClasses="dataTableGestisci_Column" 
                rowOnMouseOver="this.style.backgroundColor='#FFF06F'"
                rowOnMouseOut="this.style.backgroundColor=''">  
                
                <f:facet name="header">
                    <t:outputText style="color: red;" value="FORNITORE: #{beanFornitore.ragioneSociale}"/>
                </f:facet>    
                
                <t:column width="40%">
                    <f:facet name="header"  >
                        <t:outputText value="Descrizione Operazione" />
                    </f:facet>
                    <t:outputText value="#{lista.descrizione}"/> 
                </t:column>                     
                    
                <t:column width="10%" style="text-align: right; background: #F06150;">
                    <f:facet name="header">
                        <t:outputText value="Dare"/>
                    </f:facet>
                    <t:outputText value="#{lista.dare}" >                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText> 
                </t:column>      
                    
                <t:column width="10%" style="text-align: right; background: #C1E0C0;">
                    <f:facet name="header"  >
                        <t:outputText value="Avere" />
                    </f:facet>
                    <t:outputText value="#{lista.avere}">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText>
                </t:column>      
                
                <t:column width="10%" style="text-align: right; background: #FFF06F;">
                    <f:facet name="header"  >
                        <t:outputText value="Differenza" />
                    </f:facet>
                    <t:outputText value="#{lista.differenza}">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText> 
                </t:column>      
            </t:dataTable>  
            <f:verbatim></div></f:verbatim>                           
        </t:panelTab>   
            
    </t:panelTabbedPane>             
    
    <h:form id="erroriDataBase" rendered="false">
        <f:verbatim><table><td align="left" class="messaggiErrore" height="2px"></f:verbatim>           
        <h:messages style="color: red" showDetail="true" showSummary="false"/>
        <f:verbatim></td></table></f:verbatim>
    </h:form>        
    
    <jsp:include page="/piePagina.jsp"/>      
</f:view>